package com.OnTimeTeam.OnTime;



import java.io.File;

import android.app.ProgressDialog;

import android.os.AsyncTask;

import android.widget.Toast;

public class FilesSystemAsyncTask extends AsyncTask<String, Void, Boolean> {

    ProgressDialog progressDialog;
    private Toast resultToast; 
	private FileSystem host;
	private File file;

	
	public FilesSystemAsyncTask(FileSystem host, Toast resultToast,  File file) {
		
		this.host = host;
		this.resultToast = resultToast;
		this.file = file;


	}
	
    protected Boolean doInBackground(String... params) {//In Background

    	return host.refreshList(file);
    }      

    protected void onPreExecute() {//Before
    	super.onPreExecute();

    	progressDialog = ProgressDialog.show(host, host.getResources().getString(R.string.searching), host.getResources().getString(R.string.pleaseWait));
    }
    
    protected void onPostExecute(Boolean result) {//After

    	progressDialog.dismiss();
    	
    	if(result) {
    		host.updateViewAfterRefresh();
    	}
    	else {
    		resultToast.show();
    	}

    }
	
    protected void onProgressUpdate(Void... values) {
    	
    	
    }
}

